export const state = () => ({ menu: [], hotPlace: [] })

export const mutations = {
  setMenu(state, val) {
    state.menu = val
  },
  setHotPlace(state, val) {
    state.hotPlace = val
  }
}

export const actions = {
  async updateHotPlace({ commit }, city) {
    const {
      status, data: { result }
    } = await this.$axios.get('/search/hotPlace', {
      params: {
        city
      }
    })
    console.log('store', city, result)
    commit('setHotPlace', status === 200 ? result : [])
  },
  setMenu: ({
    commit
  }, menu) => {
    commit('setMenu', menu)
  },
  setHotPlace: ({
    commit
  }, hotPlace) => {
    commit('setHotPlace', hotPlace)
  }
}

// export default { namespaced: true, state, mutations, actions }
